<template>
    <div>
        <router-link tag="div" to="/" class="iconfont icon-back">&#xe624;</router-link>
        <div class="banner" @click="handleGallaryShow">
            <img class="img" :src="img" alt="">
            <div class="num"><span class="iconfont">&#xe600;</span>&nbsp;{{ num }}</div>
            <div class="title">{{ name }}</div>
        </div>
        <fade>
            <banner-gallary :list="list" v-show="showGallary" @handleClose="handleGallaryClose"></banner-gallary>
        </fade>
    </div>
</template>

<script>
import BannerGallary from 'common/gallary/Gallary'
import Fade from 'common/fade/Fade'

export default {
  name: 'DetailBanner',
  components: {
    BannerGallary,
    Fade
  },
  props: {
    name: String,
    img: String,
    list: Array
  },
  data () {
    return {
      showGallary: false
    }
  },
  computed: {
    num () {
      return this.list.length
    }
  },
  methods: {
    handleGallaryShow () {
      this.showGallary = true
    },
    handleGallaryClose () {
      this.showGallary = false
    }
  }
}
</script>

<style lang="stylus" scoped>
.icon-back
    z-index 5
    position absolute
    top .1rem
    left .1rem
    width .72rem
    line-height .72rem
    text-align center
    background-color rgba(0, 0, 0, .5)
    font-weight bold
    font-size .34rem
    color #fff
    border-radius 50%
.banner
    overflow hidden
    position relative
    width 100%
    height 0
    padding-bottom 54.93%
    background-color #ccc
    color #fff
    .img
        width 100%
    .num
        position absolute
        bottom .7rem
        left .3rem
        line-height .36rem
        padding .05rem .2rem
        background-color rgba(0, 0, 0, .5)
        font-size .3rem
        border-radius .4rem
    .title
        position absolute
        bottom 0
        left 0
        width 100%
        padding .2rem .3rem
        background-image linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, .8))
        line-height .36rem
        font-size .36rem
</style>
